package edu.sctu.fengleilin.month06.day150614;

import java.io.*;

/**
 * Created by user09 on 2015/6/14.
 */
public class IOUtil {
    public void IOUtil(){
    int countbyte = 0;
    int count = 0;
    FileInputStream fileInputStream;
    FileOutputStream fileOutputStream;
    char cha = 'A';

        try {
            fileInputStream = new FileInputStream(new File("D://d.txt"));
            fileOutputStream = new FileOutputStream(new File("D://c.txt"));
            try {
                while ((countbyte = fileInputStream.read()) != -1){
                count+=countbyte;
fileOutputStream.write(countbyte);
                }
                System.out.println(count);
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                fileInputStream.close();
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
    public void fileReader(){
        int i = 0;
        try {
            FileReader fileReader = new FileReader(new File("D://c.txt"));
            char[] buffer = new char[1024];
            try {
                while ((i = fileReader.read(buffer)) != -1){
                    System.out.println(new String(buffer));
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}